<template>
  <div class="app-container search-table-box aidex-table">
    <el-card shadow="never" ref="queryRef" style="margin-bottom: 12px;" class="search_card" v-show="showSearch">
      <div class="filter-container">
        <div class="search_box">
          <el-form :model="queryParams" ref="queryForm" label-width="120px" size="mini">
            <el-row :gutter="16">
              <el-col :md="6" >
                <el-form-item label="公司代码" prop="companycode">
                  <el-input v-model="queryParams.params.companynames" maxlength = 0 clearable placeholder="请选择公司代码" >
                    <el-button slot="append" icon="el-icon-search" @click="openSearchcompanycodeDialogOpen">
                    </el-button>
                  </el-input>
                </el-form-item>
              </el-col>
              <el-col :md="6" >
                <el-form-item label="仓库代码" prop="stockcode">
                  <el-input
                    v-model="queryParams.stockcode"
                    placeholder="请输入仓库代码"
                    clearable
                    @keyup.enter.native="handleQuery"
                  />
                </el-form-item>
              </el-col>
              <el-col :md="6" >
                <el-form-item label="仓库名称" prop="stockname">
                  <el-input
                    v-model="queryParams.stockname"
                    placeholder="请输入仓库名称"
                    clearable
                    @keyup.enter.native="handleQuery"
                  />
                </el-form-item>
              </el-col>
              <el-col :md="6" v-if="advanced">
                <el-form-item label="是否WMS管控仓" prop="iswmsmanage">
                  <el-select v-model="queryParams.iswmsmanage" placeholder="请选择是否WMS管控仓" @change="handleQuery" clearable style="width: 100%;">
                    <el-option
                      v-for="dict in dict.type.ECIsAll"
                      :key="dict.value"
                      :label="dict.label"
                      :value="dict.value"
                    />
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :md="6" v-if="advanced">
                <el-form-item label="WMS仓代码" prop="wmszonecode">
                  <el-input
                    v-model="queryParams.wmszonecode"
                    placeholder="请输入WMS仓代码"
                    clearable
                    @keyup.enter.native="handleQuery"
                  />
                </el-form-item>
              </el-col>
              <el-col :md="6" v-if="advanced">
                <el-form-item label="仓库类型" prop="stocktype">
                  <el-select v-model="queryParams.stocktype" placeholder="请选择仓库类型" @change="handleQuery" clearable style="width: 100%;">
                    <el-option
                      v-for="dict in dict.type.StockType"
                      :key="dict.value"
                      :label="dict.label"
                      :value="dict.value"
                    />
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :md="6" v-if="advanced">
                <el-form-item label="是否启用" prop="isenable">
                  <el-select v-model="queryParams.isenable" placeholder="请选择是否启用" @change="handleQuery" clearable style="width: 100%;">
                    <el-option
                      v-for="dict in dict.type.sys_normal_enable"
                      :key="dict.value"
                      :label="dict.label"
                      :value="dict.value"
                    />
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :md="6" align="right" style="float: right;">
                <el-form-item>
                  <el-button class="filter-item" type="primary" @click="handleQuery">搜索</el-button>
                  <el-button class="filter-item" style="margin-left: 8px" @click="resetQuery">重置</el-button>
                  <a @click="toggleAdvanced" style="margin:0 4px 0 8px ;vertical-align: middle;">
                    {{ advanced ? '收起' : '展开' }}
                    <i :class="advanced ? 'el-icon-arrow-up' : 'el-icon-arrow-down'"></i>
                  </a>
                </el-form-item>
              </el-col>
            </el-row>
          </el-form>
        </div>
      </div>
    </el-card>
    <el-card shadow="never" >
      <template #header>
        <el-row>
          <el-col :span="8">
            <div class="card-header">
              <el-button disabled type="text">仓库信息</el-button>
            </div>
          </el-col>
          <el-col :span="16">
            <div class="btn_box" align="right" style="float: right;">
              <el-button
                class="filter-item"
                style="margin-left: 8px;"
                type="primary"
                icon="el-icon-plus"
                @click="handleAdd"
                size="mini"
                v-hasPermi="['core:stock:add']"
              >新增</el-button>
              <el-button
                class="filter-item"
                style="margin-left: 8px;"
                icon="el-icon-delete"
                type="danger"
                :disabled="multiple"
                @click="handleDelete"
                size="mini"
                v-if="!multiple"
                v-hasPermi="['core:stock:remove']"
              >删除</el-button>
              <el-button
                class="filter-item"
                style="margin-left: 8px;"
                icon="el-icon-download"
                @click="handleExport"
                size="mini"
                v-hasPermi="['core:stock:export']"
              >导出</el-button>
              <right-toolbar :showSearch.sync="showSearch" @showSearchFun="showSearchFun" @queryTable="getList"></right-toolbar>
            </div>
          </el-col>
        </el-row>
      </template>

      <el-table
        border
        stripe
        default-expand-all
        ref="tableRef"
        v-loading="loading"
        :data="stockList"
        @selection-change="handleSelectionChange"
        :row-style="rowClass"
        :header-cell-style= "{
                'font-size': '14px !important',
                'font-weight': '500 !important',
                'background-color':'rgb(241 241 241 / 52%)'
              }"
        highlight-current-row style="width: 100%;"
        :height="tableHeight"
      >
        <el-table-column type="selection" width="55" align="center" />
        <el-table-column label="仓库ID" align="center" prop="stockid" />
        <el-table-column label="公司" align="center" prop="companyname" />
        <el-table-column label="仓库代码" align="center" prop="stockcode" />
        <el-table-column label="仓库" align="center" prop="stockname" />
        <el-table-column label="是否WMS管控仓" align="center" prop="iswmsmanage">
          <template slot-scope="scope">
            <dict-tag :options="dict.type.ECIsAll" :value="scope.row.iswmsmanage"/>
          </template>
        </el-table-column>
        <el-table-column label="WMS仓代码" align="center" prop="wmszonecode" />
        <el-table-column label="仓库类型" align="center" prop="stocktype">
          <template slot-scope="scope">
            <dict-tag :options="dict.type.StockType" :value="scope.row.stocktype"/>
          </template>
        </el-table-column>
        <el-table-column label="是否启用" align="center" prop="isenable">
          <template slot-scope="scope">
            <dict-tag :options="dict.type.sys_normal_enable" :value="scope.row.isenable"/>
          </template>
        </el-table-column>
        <el-table-column label="仓库属性" align="center" prop="stockattribute" />
        <el-table-column label="商品状态" align="center" prop="productstatus" />
        <el-table-column label="备注" align="center" prop="remark" />
        <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="220">
          <template slot-scope="scope">
            <el-button
              type="text"
              @click="handleUpdate(scope.row)"
              v-hasPermi="['core:stock:edit']"
            >修改</el-button>
            <el-divider direction="vertical"></el-divider>
            <el-button
              type="text"
              style="color: red;"
              @click="handleDelete(scope.row)"
              v-hasPermi="['core:stock:remove']"
            >删除</el-button>
          </template>
        </el-table-column>
        <div slot="empty">
          <svg-icon icon-class="search-none" style="font-size: 64px;" />
          <p>暂无数据</p>
        </div>
      </el-table>

      <pagination
        v-show="total>0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
      />

      <!-- 添加或修改仓库对话框 -->
      <el-dialog :close-on-click-modal="false" :title="title" :visible.sync="open" width="720px" top="10vh" append-to-body>
        <div style="height: 490px;overflow: auto; padding: 12px 24px;">
          <el-form ref="form" size="mini" :model="form" :rules="rules" label-position="top">
            <el-row :gutter="24">
              <el-col :span="12">
                <el-form-item label="公司" prop="companycode">
                  <el-input
                    v-model="form.companyname"
                    maxlength = 0
                    clearable
                    readonly
                    placeholder="请选择公司代码"
                  >
                    <el-button slot="append" icon="el-icon-search" @click="opencompanycodeDialogOpen">
                    </el-button>
                  </el-input>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="仓库代码" prop="stockcode">
                  <el-input v-model="form.stockcode" placeholder="请输入仓库代码" />
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="仓库" prop="stockname">
                  <el-input v-model="form.stockname" placeholder="请输入仓库" />
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="是否WMS管控仓" prop="iswmsmanage">
                  <el-select v-model="form.iswmsmanage" placeholder="请选择是否WMS管控仓" clearable style="width: 100%;">
                    <el-option
                      v-for="dict in dict.type.ECIsAll"
                      :key="dict.value"
                      :label="dict.label"
                      :value="parseInt(dict.value)"
                    ></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="WMS仓代码" prop="wmszonecode">
                  <el-input v-model="form.wmszonecode" placeholder="请输入WMS仓代码" />
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="仓库类型" prop="stocktype">
                  <el-select v-model="form.stocktype" placeholder="请选择仓库类型" clearable style="width: 100%;">
                    <el-option
                      v-for="dict in dict.type.StockType"
                      :key="dict.value"
                      :label="dict.label"
                      :value="dict.value"
                    ></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="是否启用" prop="isenable">
                  <el-select v-model="form.isenable" placeholder="请选择是否启用" clearable style="width: 100%;">
                    <el-option
                      v-for="dict in dict.type.sys_normal_enable"
                      :key="dict.value"
                      :label="dict.label"
                      :value="parseInt(dict.value)"
                    ></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="仓库属性" prop="stockattribute">
                  <el-input v-model="form.stockattribute" placeholder="请输入仓库属性" />
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="备注" prop="remark">
                  <el-input v-model="form.remark" placeholder="请输入备注" />
                </el-form-item>
              </el-col>
            </el-row>
          </el-form>
        </div>
        <div slot="footer" class="dialog-footer">
          <el-button type="primary"  size="mini" @click="submitForm">确 定</el-button>
          <el-button  size="mini" @click="cancel">取 消</el-button>
        </div>
      </el-dialog>

      <!-- 查询条件-公司-弹出查询 -->
      <el-dialog v-dialogDrag  :close-on-click-modal="false" title="查询条件-公司查询" :visible.sync="searchcompanycodeDialogOpen" width="800px" append-to-body>
        <div class="dialog_box" style="height:550px;">
          <el-form label-position="left" :model="searchcompanycodeQueryParams" :inline="true"  ref="searchcompanycodeQueryForm" label-width="88px" >
            <el-form-item  prop="searchcompanycodeSearchValue">
              <el-input
                v-model="searchcompanycodeQueryParams.searchValue"
                size="mini"
                placeholder="请输入编码或名称查询公司"
                @keyup.enter.native="handleSearchcompanycodeQuery"
                clearable
              />
            </el-form-item>
            <el-form-item>
              <el-button type="primary" icon="el-icon-search" size="mini" @click="handleSearchcompanycodeQuery">查询</el-button>
            </el-form-item>
          </el-form>
          <el-table v-loading="searchcompanycodeSelectLoading" :data="searchcompanycodeList"
                    height="400"
                    @row-click="handleSearchcompanycodeRowClick"
                    ref="searchcompanycodeMultipleTable"
                    :row-key="getSearchcompanycodeListRowKey"
                    :row-style="{height:2+'px'}"
                    :header-cell-style= "{
                        'font-size': '14px !important',
                        'font-weight': '500 !important',
                        'background-color':'rgb(241 241 241 / 52%)'
                      }"
                    :cell-style="{padding:'2px 4px'}"
                    border
                    @selection-change="handleSearchcompanycodeSelectionChange">
            <el-table-column type="selection" width="55" align="center"/>
            <!-- 数据 -->
            <el-table-column prop="siteCode" label="组织编码" width="180"></el-table-column>
            <el-table-column prop="siteName" label="组织名称" ></el-table-column>
            <el-table-column prop="propertyTypeName" label="性质" width="150"></el-table-column>
          </el-table>
          <pagination
            v-show="searchcompanycodeTotal>0"
            :total="searchcompanycodeTotal"
            :page.sync="searchcompanycodeQueryParams.pageNum"
            :limit.sync="searchcompanycodeQueryParams.pageSize"
            @pagination="getSearchcompanycodeList"
          />
        </div>
        <div slot="footer" class="dialog-footer">
          <el-button size="mini" type="primary" @click="confirmSearchcompanycode">确 定</el-button>
          <el-button size="mini"   @click="searchcompanycodeCancel">取 消</el-button>
        </div>
      </el-dialog>

      <!-- 编辑-公司-弹出查询 -->
      <el-dialog v-dialogDrag  :close-on-click-modal="false" title="编辑仓库-公司选择" :visible.sync="companycodeDialogOpen" width="800px" append-to-body>
        <div class="dialog_box" style="height:550px;">
          <el-form label-position="left" :model="companycodeQueryParams" :inline="true"  ref="companycodeQueryForm" label-width="88px" >
            <el-form-item  prop="companycodeSearchValue">
              <el-input
                v-model="companycodeQueryParams.searchValue"
                size="mini"
                placeholder="请输入编码或名称查询公司"
                @keyup.enter.native="handlecompanycodeQuery"
                clearable
              />
            </el-form-item>
            <el-form-item>
              <el-button type="primary" icon="el-icon-search" size="mini" @click="handleSearchcompanycodeQuery">查询</el-button>
            </el-form-item>
          </el-form>
          <el-table v-loading="companycodeSelectLoading" :data="companycodeList"
                    height="400"
                    @row-click="handlecompanycodeRowClick"
                    ref="companycodeSingleTable"
                    :row-key="getcompanycodeListRowKey"
                    :row-style="{height:2+'px'}"
                    :header-cell-style= "{
                        'font-size': '14px !important',
                        'font-weight': '500 !important',
                        'background-color':'rgb(241 241 241 / 52%)'
                      }"
                    :cell-style="{padding:'2px 4px'}"
                    border
                    @selection-change="handlecompanycodeSelectionChange">
            <el-table-column label="选择" width="60">
              　　　　<template slot-scope="scope">
              　　　　　　<el-radio v-model="companycodeDialogRadio" :label="scope.row"><i></i></el-radio>
              　　　　</template>
              　　 </el-table-column>
            <!-- 数据 -->
            <el-table-column prop="siteCode" label="组织编码" width="180"></el-table-column>
            <el-table-column prop="siteName" label="组织名称" ></el-table-column>
            <el-table-column prop="propertyTypeName" label="性质" width="150"></el-table-column>
          </el-table>
          <pagination
            v-show="companycodeTotal>0"
            :total="companycodeTotal"
            :page.sync="companycodeQueryParams.pageNum"
            :limit.sync="companycodeQueryParams.pageSize"
            @pagination="getcompanycodeList"
          />
        </div>
        <div slot="footer" class="dialog-footer">
          <el-button size="mini" type="primary" @click="confirmcompanycode">确 定</el-button>
          <el-button size="mini" @click="companycodeCancel">取 消</el-button>
        </div>
      </el-dialog>




    </el-card>
  </div>
</template>

<script>
    import { listStock, getStock, delStock, addStock, updateStock } from "@/api/core/stock";
    import { listCompany as listcompany, getCompany as getcompany } from "@/api/core/company";

    export default {
        name: "Stock",
        dicts: ['ECIsAll', 'sys_normal_enable', 'StockType'],
        data() {
            return {
                advanced: false,
                tableHeight: this.getInitTableHeight(),
                // 遮罩层
                loading: true,
                // 选中数组
                ids: [],
                // 非单个禁用
                single: true,
                // 非多个禁用
                multiple: true,
                // 显示搜索条件
                showSearch: true,
                // 总条数
                total: 0,
                // 仓库表格数据
                stockList: [],
                // 弹出层标题
                title: "",
                // 是否显示弹出层
                open: false,
                // 查询参数
                queryParams: {
                    pageNum: 1,
                    pageSize: 10,
                    params:{

                    },
                    companycode: null,
                    stockcode: null,
                    stockname: null,
                    iswmsmanage: null,
                    wmszonecode: null,
                    stocktype: null,
                    isenable: null,
                    productstatus: null,
                },
                // 表单参数
                form: {},
                // 表单校验
                rules: {
                    companycode: [
                        { required: true, message: "公司代码不能为空", trigger: "blur" }
                    ],
                    stockcode: [
                        { required: true, message: "仓库代码不能为空", trigger: "blur" }
                    ],
                    stockname: [
                        { required: true, message: "仓库不能为空", trigger: "blur" }
                    ],
                    iswmsmanage: [
                        { required: true, message: "是否WMS管控仓不能为空", trigger: "change" }
                    ],
                    wmszonecode: [
                        { required: true, message: "WMS仓代码不能为空", trigger: "blur" }
                    ],
                    stocktype: [
                        { required: true, message: "仓库类型不能为空", trigger: "change" }
                    ],
                    isenable: [
                        { required: true, message: "是否启用不能为空", trigger: "change" }
                    ],
                    stockattribute: [
                        { required: true, message: "仓库属性不能为空", trigger: "blur" }
                    ],
                    productstatus: [
                        { required: true, message: "商品状态不能为空", trigger: "change" }
                    ],
                },


                /* ======================================查询条件-公司代码选择======================================  */
                searchcompanycodes:[],
                searchcompanycodenames:[],
                searchcompanycodeTotal: 0,
                searchcompanycodeList: [],
                searchcompanycodeDialogOpen: false,
                searchcompanycodeSelectLoading: false,
                searchcompanycodeQueryParams: {
                    searchValue: null,
                    pageNum: 1,
                    pageSize: 20,
                },
                /* ======================================编辑-公司代码选择======================================  */
                companycodename: null,
                companycodeTotal: 0,
                companycodeList: [],
                companycodeDialogRadio: null,
                companycodeDialogOpen: false,
                companycodeSelectLoading: false,
                companycodeQueryParams: {
                    searchValue: null,
                    pageNum: 1,
                    pageSize: 20,
                },
            };
        },
        created() {
            this.getList();
        },
        methods: {
            /** 行样式 */
            rowClass({ row, rowIndex }) {
                if (this.ids.includes(row.id)) {
                    return { background: "#d9edf7", height:'20px' };
                } else {
                    return { height:'20px'};
                }
            },
            /** 隐藏搜索按钮操作 */
            showSearchFun(isShowSearch){
                this.showSearch = isShowSearch
                let oldHeight = this.$refs.queryRef.$el.offsetHeight
                if(!isShowSearch){
                    //当前是显示状态
                    oldHeight = oldHeight + 12
                }else{
                    oldHeight = oldHeight - 12
                }
                this.$nextTick(() => (
                    this.tableHeight = this.$refs.tableRef.$el.offsetHeight - (this.$refs.queryRef.$el.offsetHeight-oldHeight)
                ))
            },
            /** 展开按钮操作 */
            toggleAdvanced() {
                const oldHeight = this.$refs.queryRef.$el.offsetHeight
                this.advanced = !this.advanced
                this.$nextTick(() => (
                    this.tableHeight = this.$refs.tableRef.$el.offsetHeight - (this.$refs.queryRef.$el.offsetHeight-oldHeight)
                ))
            },
            /** 查询仓库列表 */
            getList() {
                this.loading = true;
                listStock(this.queryParams).then(response => {
                    this.stockList = response.rows;
                    this.total = response.total;
                    this.loading = false;
                });
            },
            // 取消按钮
            cancel() {
                this.open = false;
                this.reset();
            },
            // 表单重置
            reset() {
                this.form = {
                    stockid: null,
                    companyname: null,
                    companycode: null,
                    stockcode: null,
                    stockname: null,
                    iswmsmanage: null,
                    wmszonecode: null,
                    stocktype: null,
                    isenable: null,
                    stockattribute: null,
                    productstatus: null,
                    remark: null
                };
                this.resetForm("form");
            },


            /* ※※ 查询 公司代码 相关方法 start ※※ */
            /** ① 弹出查询条件-公司代码 */
            openSearchcompanycodeDialogOpen(){
                this.searchcompanycodeDialogOpen = true;
                // 默认不查询
            },
            /** ② 单击行 **/
            handleSearchcompanycodeRowClick(row, column, event){
                this.$refs.searchcompanycodeSingleTable.toggleRowSelection(row);
            },
            /** ③ 行KEY **/
            getSearchcompanycodeListRowKey(row) {
                return row.companycode
            },
            /** ④ 选中公司代码 **/
            handleSearchcompanycodeSelectionChange(selection) {
                this.searchcompanycodes = selection.map(item => item.companycode);
                this.searchcompanycodenames = selection.map(item => item.companyname);
            },
            /** ⑤ 点击查询按钮 **/
            handleSearchcompanycodeQuery(){
                this.searchcompanycodeQueryParams.pageNum = 1;
                this.getSearchcompanycodeList();
            },
            /** ⑥ 查询 **/
            getSearchcompanycodeList(){
                this.searchcompanycodeSelectLoading = true;
                listcompany(this.searchcompanycodeQueryParams).then(response => {
                    this.searchcompanycodeList = response.rows;
                    this.searchcompanycodeTotal = response.total;
                    this.searchcompanycodeSelectLoading = false;
                });
            },
            /** ⑦ 点击确认查询 **/
            confirmSearchcompanycode() {
                if(this.searchcompanycodes.length > 0){
                    this.queryParams.params.companycodes = this.searchcompanycodes.join(',');
                    this.queryParams.params.companynames = this.searchcompanycodenames.join(',');
                }
                // 关闭查询弹出框
                this.searchcompanycodeCancel();
            },
            /** ⑧ 点击关闭查询弹出框 **/
            searchcompanycodeCancel() {
                this.searchcompanycodeDialogOpen = false;
            },
            /* ※※ 查询 公司代码 相关方法 end ※※ */


            /* ※※ 编辑 公司代码 相关方法 start ※※ */
            /** ① 弹出编辑内容-公司代码 */
            opencompanycodeDialogOpen(){
                this.companycodeDialogOpen = true;
                this.getcompanycodeList();
            },
            /** ② 单击行 **/
            handlecompanycodeRowClick(row, column, event){
                this.$refs.companycodeSingleTable.toggleRowSelection(row);
            },
            /** ③ 行KEY **/
            getcompanycodeListRowKey(row) {
                return row.companycode
            },
            /** ④ 选中公司代码 **/
            handlecompanycodeSelectionChange(selection) {
                if (selection[0]) {
                    this.companycodeDialogRadio = selection[0]
                    this.form.companycode = selection[0].companycode;
                    this.form.companyname = selection[0].companyname;
                }
            },
            /** ⑤ 点击查询按钮 **/
            handlecompanycodeQuery(){
                this.companycodeQueryParams.pageNum = 1;
                this.getcompanycodeList();
            },
            /** ⑥ 查询 **/
            getcompanycodeList(){
                this.companycodeSelectLoading = true;
                listcompany(this.companycodeQueryParams).then(response => {
                    this.companycodeList = response.rows;
                    this.companycodeTotal = response.total;
                    this.companycodeSelectLoading = false;
                });
            },
            /** ⑦ 点击确认查询 **/
            confirmcompanycode() {
                this.companycodeCancel();
            },
            /** ⑧ 点击关闭查询弹出框 **/
            companycodeCancel() {
                this.companycodeDialogOpen = false;
            },
            /* ※※ 编辑 公司代码 相关方法 end ※※ */


            /** 搜索按钮操作 */
            handleQuery() {
                this.queryParams.pageNum = 1;
                this.getList();
            },
            /** 重置按钮操作 */
            resetQuery() {
                this.resetForm("queryForm");
                this.handleQuery();
            },
            // 多选框选中数据
            handleSelectionChange(selection) {
                this.ids = selection.map(item => item.stockid)
                this.single = selection.length!==1
                this.multiple = !selection.length
            },
            /** 新增按钮操作 */
            handleAdd() {
                this.reset();
                this.open = true;
                this.title = "添加仓库";
            },
            /** 修改按钮操作 */
            handleUpdate(row) {
                this.reset();
                const stockid = row.stockid || this.ids
                getStock(stockid).then(response => {
                    this.form = response.data;
                    this.open = true;
                    this.title = "修改仓库";
                });
            },
            /** 提交按钮 */
            submitForm() {
                this.$refs["form"].validate(valid => {
                    if (valid) {
                        if (this.form.stockid != null) {
                            updateStock(this.form).then(response => {
                                this.$modal.msgSuccess("修改成功");
                                this.open = false;
                                this.getList();
                            });
                        } else {
                            addStock(this.form).then(response => {
                                this.$modal.msgSuccess("新增成功");
                                this.open = false;
                                this.getList();
                            });
                        }
                    }
                });
            },
            /** 删除按钮操作 */
            handleDelete(row) {
                const stockids = row.stockid || this.ids;
                this.$modal.confirm('是否确认删除仓库编号为"' + stockids + '"的数据项？').then(function() {
                    return delStock(stockids);
                }).then(() => {
                    this.getList();
                    this.$modal.msgSuccess("删除成功");
                }).catch(() => {});
            },
            /** 导出按钮操作 */
            handleExport() {
                this.download('core/stock/export', {
                    ...this.queryParams
                }, `stock_${new Date().getTime()}.xlsx`)
            }
        }
    };
</script>
